from django.db import models
from django.contrib.auth.models import User
from mysite.blog.models import Author,Tag

class Note(models.Model):
    id = models.AutoField(primary_key=True)
    title = models.CharField(maxlength=45)
    body = models.TextField()
    last_mod = models.DateTimeField(auto_now=True)
    pub_date = models.DateTimeField(auto_now_add=True)
    author = models.ForeignKey(Author)
    #tag = models.ForeignKey(Tag)
    slug = models.SlugField(
        unique_for_date='pub_date',
        prepopulate_from=('title',),
        help_text='Wypełniane automatycznie',
    )
    def __str__ (self):
        return self.title
    class Meta:
        ordering = ('-pub_date',)
        get_latest_by = 'pub_date'
        
    class Admin:
        list_display = ('title', 'author','slug','id','pub_date')
        list_filter = ['pub_date']
        search_fields = ['tytul']
        search_fields = ['body']
        date_hierarchy = 'pub_date'
        pass
    